<template>
  <div>
      <div class="item-box" v-for="(item, index) in list" :key="index" :class="{'active' : index === current}"  @click="selectMaterial(index)">
          <div class="select-wrap">
              <span class="icon" v-if="index !== 1"></span>
              <span class="icon active" v-else><i class="el-icon-check"></i></span>
          </div>
          <div class="header">
              <span class="name">名称001名称001</span>
              <span class="no">|</span>
              <span class="code">CGTLSQ20221010002</span>
          </div>
          <div class="content">
              <div class="line">
                  <div class="info">
                      <span class="name">特征参数:</span>
                      <span class="val">红色/白色/长/宽/高</span>
                  </div>
              </div>
              <div class="line">
                <div class="info">
                      <span class="name">批次号:</span>
                      <span class="val">picihao001</span>
                  </div>
              </div>
              <div class="line flex">
                  <div class="info">
                      <span class="name">库区名称:</span>
                      <span class="val">10000</span>
                  </div>
                  <div class="info">
                      <span class="name">库位名称:</span>
                      <span class="val">君兰仓库</span>
                  </div>
              </div>
              <div class="line flex">
                  <div class="info">
                      <span class="name">库存数量:</span>
                      <span class="val">10000</span>
                  </div>
                  <div class="info">
                      <span class="name">批次品质:</span>
                      <span class="val">君兰仓库</span>
                  </div>
              </div>
              <div class="line">
                <div class="info">
                      <span class="name">批次备注:</span>
                      <span class="val">备注内容备注内容备注内容备注内内</span>
                  </div>
              </div>
          </div>
      </div>
  </div>
</template>

<script>
// import MaterialContent from "./MaterialContent.vue";
export default {
name: 'ListItem',
components: {
  // MaterialContent,
},
props: {
  list: {
    type: Array,
    default: () => [],
    required: true
  }
},
  data() {
      return {
          current: null,
      // isShow: false,
      }
  },
  methods: {
      selectMaterial(index) {
          // this.isShow = true;
          this.current = index
          this.$emit('selectMaterial', this.list[index])
      }
  }

}
</script>

<style lang="scss" scoped>
.item-box{
  margin: 0 0 12px;
  background-color: #ffffff;
  border-radius: 4px;
  box-shadow: 0px 3px 6px 1px rgba(0,0,0,0.16);
  padding: 12px 12px 12px 27px;
  font-size: 14px;
  color: #333333;
  border: 1px #ffffff solid;
  position: relative;
  &.active{
      border: 1px #548AF1 solid;
      &::after{
          content: '';
          width: 4px;
          height: 100%;
          background-color: #548AF1;
          position: absolute;
          left: 0;
          top: 0;
          bottom: 0;
      }
  }
  .select-wrap{
      position: absolute;
      left: 5px;
      top: 15px;
      .icon{
        width: 14px;
        height: 14px;
        border: 1px #DBDBDB solid;
        border-radius: 2px;
        margin-right: 5px;
        display: inline-block;
        &.active{
          background-color: #4286F5;
          border-color: #4286F5;
          i{
            color: #ffffff;
          }
        }
      }
  }
  .header{
      .no{
          margin: 0 4px;
      }
  }
  .content{
      padding-top: 5px;
      .line{
          margin-top: 10px;
          .name{
              color: #666666;
          }
      }
      .flex{
          display: flex;
          justify-content: space-between;

      }
  }
}
</style>